package com.tanhua.model.vo;

import com.tanhua.model.domain.Dimension;
import com.tanhua.model.domain.Result;
import com.tanhua.model.domain.UserInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ReportVo implements Serializable {
    private String conclusion;
    private String cover;
    private List<Dimension> dimensions;
    private List<SimilarYou> similarYou;

    public static ReportVo init(List<UserInfo> userInfos, Result result) {
        ReportVo reportVo = new ReportVo();
        reportVo.setConclusion(result.getConclusion());
        reportVo.setCover(result.getCover());

        List<Dimension> dimensions = new ArrayList<>();
        Dimension d1 = new Dimension();
        d1.setKey("外向");
        d1.setValue("80%");

        Dimension d2 = new Dimension();
        d2.setKey("判断");
        d2.setValue("70%");

        Dimension d3 = new Dimension();
        d3.setKey("抽象");
        d3.setValue("90%");

        Dimension d4 = new Dimension();
        d4.setKey("理性");
        d4.setValue("75%");

        Collections.addAll(dimensions, d1, d2, d3, d4);

        List<SimilarYou> similarYou = new ArrayList<>();
        for (UserInfo userInfo : userInfos) {
            SimilarYou sy = new SimilarYou();
            BeanUtils.copyProperties(userInfo, sy);
            similarYou.add(sy);
        }

        reportVo.setDimensions(dimensions);
        reportVo.setSimilarYou(similarYou);
        return reportVo;
    }
}
